users = ["root", "westos"]

passwd = ["123", "456"]

for i in range(3):
    username = input("请输入用户名:\n")
    if username in users:
        password = input("请输入密码:\n")
        if password == passwd[users.index(username)]:
            print("登录成功!")
            break
        else:
            print(f"密码错误!请重新登录,剩余{2-i}次机会!")
    else:
        print(f"用户不存在!请重新登录,剩余{2-i}次机会!")
